import request from '@/utils/request'
import { downloadTemplate } from '@/utils/download'
import { getCurrentTime } from '@/utils'

const pref = '/sysMajorCategory'

export const getPage = (param) => {
  return request.post(pref + '/getPage', param)
}

export const getTree = () => {
  return request.get(pref + '/getTree', {
    'timeout': 50000
  })
}

export const deleteById = (id) => {
  return request.delete(pref + '?id=' + id)
}

export const save = (param) => {
  return request.post(pref, param)
}

export const getOne = (id) => {
  return request.get(pref + '?id=' + id)
}

export const downloadExcelTemplate = () => {
  return downloadTemplate(pref, {}, {}, getCurrentTime() + '.xlsx')
}

export const importMajor = (id) => {
  return request.get(pref + '/importMajor?id=' + id, {
    'timeout': 50000
  })
}
